<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE6">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="Author" content="">
		<meta name="Keywords" content="">
		<meta name="Description" content="">
		<link rel="stylesheet" type="text/css" href="<%=basePath%>css/all_b.css?20161126">
		<title>${user.userNo} - 设置密码</title>
		<link rel="shortcut icon" href="<%=basePath%>favicon.ico">
		<script type="text/javascript" src="<%=basePath%>js/jquery.min.js?20161126"></script>
		<script type="text/javascript" src="<%=basePath%>js/layer/layer.js?20161126"></script>
	</head>
	<body style="" id="bodyModule">
		<jsp:include page="../commons/manage_head.jsp" flush="true"></jsp:include>
		<div style="height:580px;" id="layout" class="container">
			<div style="display: block;" id="rightLoader" dom="right"
				class="main-content bet-content">
				<div id="dagudong" class=" member">
					<div class="title">
						<span id="account_name">修改密码</span>
						<a href="javascript:history.go(-1)" id="reback" level="1"
							class="mag-btn1">返回</a>
					</div>
					<div id="user_info">
						<form class="ant-form-horizontal"
									action="<%=basePath%>user/update_user">
									<table class="clear-table base-info">
										<colgroup>
											<col class="col_single">
											<col>
										</colgroup>
										<thead>
											<tr>
												<th colspan="2">
													修改密码
												</th>
											</tr>
										</thead>
										<tbody>
											<tr>
												<td height="28" width="30%">
													<div class="t blueness">
														旧密码
													</div>
												</td>
												<td>
													<div class="form">
														<input class="input_t" id="password" name="oldPassword"
															maxlength="18" type="password">
														<span class="g-vd-status"></span>
													</div>
												</td>
											</tr>
											<tr>
												<td height="28">
													<div class="t blueness">
														新密码
													</div>
												</td>
												<td>
													<div class="form">
														<input class="input_t" id="newpassword" name="password"
															maxlength="18" type="password">
														<span class="g-vd-status"></span>
													</div>
												</td>
											</tr>
											<tr>
												<td height="28">
													<div class="t blueness">
														确认密码
													</div>
												</td>
												<td>
													<div class="form">
														<input class="input_t" name="passwordRepeat"
															maxlength="18" type="password">
														<span class="g-vd-status"></span>
													</div>
												</td>
											</tr>
										</tbody>
									</table>
								</form>
					</div>
					<div class="btn-line">
						<a type="button" class="yellow-btn" id="submit" onclick="updatePassword();"
							href="javascript:void(0)">确认修改</a>
					</div>
				</div>
			</div>
		</div>
		<!--[if lte IE 6.5]><![endif]-->
		<div class="g-dialog-win elem-dialog normalsize"
			style="z-index: 999999999; position: absolute; right: 3px; top: 40px; display: none;"
			id="lineSelectBox">
		</div>
		<div class="footer">
			<div class="marquee">
				<a id="moreNotice" class="more more_announcement"
					href="javascript:void(0)">更多</a>
				<p class="marqueeBox">
					<marquee id="marqueeBox" scrollamount="2">
						欢迎光临...........
					</marquee>
				</p>
			</div>
			<span id="marqueeRefresh" class="hidden">3</span>
			<span id="kefuRefresh" class="hidden"></span>
		</div>
		<script src="<%=basePath%>js/jquery.min.js?20161104"></script>
	</body>
<script type="text/javascript">
	$(function(){
		 $(document).bind("contextmenu",function(e){   
	        return false;   
	  	 });
	});
	function updatePassword(){
		var passwordRepeat = $("input[name=passwordRepeat]").val();
		var oldPassword = $("input[name=oldPassword]").val();
		var password = $("input[name=password]").val();
		if(oldPassword.trim() == ''){
			layer.msg("原密码不能为空");
			return;
		}
		if(password.trim() == ''){
			layer.msg("新密码不能为空");
			return;
		}
		if(passwordRepeat.trim() == ''){
			layer.msg("确认密码不能为空");
			return;
		}
		if(password != passwordRepeat){
			layer.msg("新密码与确认密码不一致");
			return;
		}
		$.ajax({
            type: "POST",url:$("form").attr("action"),
            data:$("form").serialize(),
            error: function(request) {
                layer.msg("Connection error");
            },success: function(data) {
            	if(data.resultCode == '5'){
            		window.location.href = "<%=basePath%>";
            	}else if(data.resultCode == '0'){
            		if(confirm("修改成功，是否确认重新登陆？")){
            			window.location.href = "<%=basePath%>manage/login";
            		}else{
            			window.location.reload();
            		}
            	}
            }
        });
	}
	</script>
</html>